home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / prodpack.zip / DB4PPSRC.EXE / _ODOMET.PRG < prev    next >
Text File  |  1993-05-04  |  4KB  |  133 lines

  1. *' $Header: $
  2. PROCEDURE _Odomet
  3. *-------------------------------------------------------------------------
  4. * NAME
  5. *   _Odomet - Display an odometer for operation status
  6. * DESCRIPTION
  7. *   _Odomet will display an Odometer in a window to show the progress
  8. *   of an operation.  _Odomet uses global variables versus parameter
  9. *   passing for performance reasons.  The odometer will always start
  10. *   at row 9.
  11. * GLOBAL VARIABLES
  12. *   gn_OdMax    = The maximum value for the odometer.
  13. *   gn_OdCur    = The current value of the odometer.  The percentage of
  14. *                 completion is based on gn_OdCur / gn_OdMax.  A value
  15. *                 of 0 will activate the odometer window.  When the value
  16. *                 equals gn_OdMax, the window will go away.
  17. *   gc_OdText   = An optional message to display.  The message is painted
  18. *                 when gn_OdCur is 0.
  19. *   gn_OdLeft   = The left most column of the odometer border inside of
  20. *                 the window.  This avoid having to calculate the value
  21. *                 during each iteration.
  22. *   gc_OdBoxCl  = Original color of box
  23. * EXAMPLE
  24. *   gn_OdMax  = 100
  25. *   gn_OdCur  = 0
  26. *   gn_OdLeft = 0           && Altered by _Odomet
  27. *   gn_OdRight = 0          && Altered by _Odomet
  28. *   gn_OdBoxCl = ""         && Altered by _Odomet
  29. *   gc_OdText = [Checking the form fields]
  30. *   DO _Odomet
  31. *   ln = 1
  32. *   DO WHILE ln <= gn_OdMax
  33. *     ....
  34. *     ln = ln + 1
  35. *     gn_OdCur = ln
  36. *     DO _Odomet
  37. *   ENDDO
  38. *
  39. * ERROR CHECKING
  40. *   _Odomet assumes that all the variables are set correctly to avoid
  41. *   the overhead of type checking.
  42. *-------------------------------------------------------------------------
  43.   IF gn_OdCur > 0
  44.     IF gn_OdCur <= gn_OdMax
  45.  
  46.       *-- Display the odometer setting
  47.       @ 1, gn_OdLeft + 1 TO ;
  48.         1, INT( gn_OdLeft + 1 + ( gn_OdCur / gn_OdMax * 25 ) ) PANEL
  49.  
  50.       RETURN
  51.     ELSE
  52.       *-- Display the odometer setting
  53.       @ 1, gn_OdLeft + 1 TO 1, gn_OdRight - 1 PANEL
  54.  
  55.       DEACTIVATE WINDOW _Odomet
  56.       RELEASE WINDOW _Odomet
  57.       RESTORE SCREEN FROM Odomet
  58.       RELEASE SCREEN Odomet
  59.       SET COLOR OF BOX TO &gc_OdBoxCl
  60.       RETURN
  61.     ENDIF
  62.   ENDIF
  63.  
  64.   IF gn_OdCur = 0
  65.     ln_LenOdom = 27
  66.     ln_Mess = 0
  67.     IF TYPE( "gc_OdText" ) = "C"
  68.  
  69.       ln_Mess = LEN( gc_OdText )
  70.       IF ln_Mess <= ln_LenOdom
  71.         ln_Width = ln_LenOdom
  72.       ELSE
  73.         IF ln_Mess > 76
  74.           gc_OdText = LEFT( gc_OdText, 76 )
  75.           ln_Mess = 76
  76.         ENDIF
  77.         ln_Width = ln_Mess
  78.       ENDIF
  79.  
  80.     ELSE
  81.       ln_Width    = ln_LenOdom
  82.     ENDIF
  83.  
  84.     ln_LeftCol  = ((76 - ln_Width) + .5) / 2
  85.     ln_RightCol = (ln_Width + 83) / 2
  86.  
  87.     gc_OdBoxCl = _ColorChk( "B" )
  88.     SET COLOR OF BOX TO w+/w
  89.     SAVE SCREEN TO Odomet
  90.     @ 10,  ln_LeftCol + 2 FILL TO 16, ln_RightCol + 2 COLOR n+/n
  91.     DEFINE WINDOW _Odomet FROM 9,  ln_LeftCol ;
  92.                           TO 15, ln_RightCol DOUBLE ;
  93.                           COLOR n/w
  94.  
  95.     ln_width    = ln_width + 2
  96.     ln_OdLeft   = (ln_width - ln_LenOdom ) / 2
  97.     gn_OdLeft   = ln_OdLeft
  98.     gn_OdRight  = ln_OdLeft + ln_LenOdom
  99.  
  100.     ACTIVATE WINDOW _Odomet
  101.  
  102.  
  103.     @ 0, ln_OdLeft SAY CHR( 218 ) COLOR n/w
  104.     @ 0, ln_OdLeft + 1 SAY REPLICATE( CHR( 196 ), ln_LenOdom - 1 ) COLOR n/w
  105.     @ 0, gn_OdRight SAY CHR( 191 ) COLOR w+/w
  106.     @ 1, ln_OdLeft SAY CHR( 179 ) COLOR n/w
  107.     @ 1, gn_OdRight SAY CHR( 179 ) COLOR w+/w
  108.     @ 2, ln_OdLeft SAY CHR( 192 ) COLOR n/w
  109.     @ 2, ln_OdLeft + 1 SAY REPLICATE( CHR( 196 ), ln_LenOdom - 1 ) COLOR w+/w
  110.     @ 2, gn_OdRight SAY CHR( 217 ) COLOR w+/w
  111.  
  112.     IF TYPE( "gc_OdText" ) = "C"
  113.       @ 3, ( ln_Width - ln_Mess ) / 2 SAY gc_OdText COLOR n/w
  114.     ENDIF
  115.  
  116.   ELSE
  117.  
  118.   ENDIF
  119.  
  120. RETURN
  121. *-- EOP: _Odomet
  122. *'----------------------------------------------------------------------------
  123. *' $Log: $
  124. *'----------------------------------------------------------------------------
  125.  
  126.